<?php
/**
 * Created by PhpStorm.
 * User: baike
 * Date: 2017/12/6
 * Time: 下午3:25
 */
/**
 * Created by PhpStorm.
 * User: baike
 * Date: 2017/11/30
 * Time: 下午3:59
 */

include "../mysql_connect.php";
include "../common.php";


isset($_REQUEST['server_id'])? $server_id=$_REQUEST['server_id']:$server_id="";
isset($_REQUEST['tm'])? $tm=$_REQUEST['tm']:$tm="";
isset($_REQUEST['sign'])? $sign=$_REQUEST['sign']:$sign="";
if($server_id=="" || $tm=="" || $sign=="")
{
    die("need serverid tm sign");
}

$arrparam=array();
$arrparam['server_id']=$server_id;
$arrparam['tm']=$tm;
if(!signcheck($arrparam,$sign))
{
    die(makeresultjson(-1,"checksum fail"));
}

if(!signcheck_indb($sign))
{
    die(makeresultjson(-2,"checksum fail 2"));
}


//print_r($arrhlname);

$sql="select store.uuid as suuid,store.merchant_uuid as muuid,store.name as sname,store.floor as floor ,store.area as area,store.industry as industry,industry.name as industryname from store inner join merchant on merchant.uuid=store.merchant_uuid left join industry on industry.id=store.industry where server_id='".$server_id."'";
$rs=mysqli_query($_SESSION['mysqli_link'],$sql);
$arr_res=array();
$arr_res['return_code']=0;
$arr_res['data']=array();

while($arrrs=mysqli_fetch_assoc($rs))
{
    array_push( $arr_res['data'],$arrrs);
}
echo json_encode($arr_res,JSON_UNESCAPED_UNICODE);